"""
    Controller for `terminal_payments` table.
"""

from mnemoply import model
from mnemoply.mass_actions import MassAction
from mnemoply.controllers import Report
from mnemoply.controllers.lookup import LookupController, TableCol, TableLookupDataSource
from mnemoply.controllers.crud import CRUDController, ItemTab
from mnemoply.utils import objs2ids

class MAPrint(MassAction):
    target_class = model.TerminalPayment
    name = "print"
    title = _("Print")
    read_only = True

    def call(self, objs):
        return Report.generate('TerminalPaymentPrint',
            ids=objs2ids(objs),
        )

class TerminalPaymentController(LookupController, CRUDController):
    model_object = model.TerminalPayment

    lookup_columns = [
        TableCol(name='register_name', caption=_("Register")),
        TableCol(name='bar_code', caption=_("Bar code")),
        TableCol(name='string_info', caption=_("String info")),
        TableCol(name='check_info', caption=_("Check info")),
        TableCol(name='sum_check', caption=_("Sum check")),
        TableCol(name='date_check', caption=_("Date check")),
        TableCol(name='bond10', caption=_("Bond 10"), hidden=True),
        TableCol(name='bond50', caption=_("Bond 50"), hidden=True),
        TableCol(name='bond100', caption=_("Bond 100"), hidden=True),
        TableCol(name='bond500', caption=_("Bond 500"), hidden=True),
        TableCol(name='bond1000', caption=_("Bond 1000"), hidden=True),
        TableCol(name='bond5000', caption=_("Bond 5000"), hidden=True),
        TableCol(name='bond_date', caption=_("Bond date"), hidden=True),
        TableCol(name='department', caption=_("Department"), hidden=True),
        TableCol(name='register_session', caption=_("Register session"), hidden=True),
        TableCol(name='inkass_session', caption=_("Inkass session"), hidden=True),
        TableCol(name='sum_coupon', caption=_("Sum coupon"), hidden=True),
        TableCol(name='addition_info', caption=_("Additional info"), hidden=True),
        ]

    def __init__(self):
        LookupController.__init__(self,
            data_source=TableLookupDataSource('terminal_payments_lookup'),
            columns=self.lookup_columns,
            mass_actions_class=self.model_object,
            title=_("Terminal payments"),
        )
        CRUDController.__init__(self, model_object=self.model_object)

exposed = TerminalPaymentController()
